<template>
	<view class="page_product">
		<!-- <uni-top2 fixed="true" statusBar="true" class="top" border="" background-color="#585cf7" color="#fff" left-icon="back" :title="pageName" @clickLeft="returnBack"></uni-top2> -->
		<!-- <view class="bg"></view> -->
		<view class="list">
			<view class="item" v-for="(item, index) in list" :key="index">
				<view class="title_sub">
					<view class="img_wrap">
						<image class="img" mode="aspectFit" :src="item.productImgUrl"></image>
					</view>
					<view class="title">{{item.productName}}
						<text class="tips">放款快</text>
						<text class="tips">利息低</text>
					</view>
					<view class="text">推广{{item.promotionCount}}次数</view>
				</view>
				<view class="brief">{{item.productBrief}}</view>
				<view class="con">
					<view class="yearRate" v-if="item.yearRate>0">年化利率：<text class="num">{{item.yearRate}}%</text>
					</view>
					<view class="explain">{{item.brokerChargeExplain}}</view>
				</view>
				<view class="extract">{{item.brokerExtract}}</view>
				<view class="btn_wrap">
					<button class="btn" @click="goToProImage(item.id)">查看推广图</button>
					<button class="btn btn1" @click="goToOrder(item.id)">我要录单</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageName: "产品线",
				list: []
			}
		},
		onLoad(option) {
			this.pageName = option.name;
			this.getProductList(option.id);
		},
		methods: {
			//返回按钮
			returnBack() {
				uni.switchTab({
					url: "/pages/index/index"
				})
			},
			//获取产品列表
			getProductList(id) {
				this.$api.getProductListById(id).then(res => {
					this.list = res.data.data;
				})
			},
			//查看推广图
			goToProImage(id) {
				console.log(id);
				uni.navigateTo({
					url: "/pages/product/productImage?id=" + id
				})
			},
			//录单
			goToOrder(id) {
				uni.navigateTo({
					url: "/pages/orderInside/addOrder?id=" + id
				})
			}
		}
	}
</script>
<style>
	page {
		max-width: 750rpx;
		margin: 0 auto;
		background: #F8F8F8;
	}
</style>
<style scoped lang="scss">
	.bg {
		width: 100%;
		height: 40rpx;
		background: $dtg-color-primary;
	}

	.list {
		margin-top: 10rpx;
		border-radius: 20rpx 20rpx 0 0;
		overflow: hidden;

		.item {
			background: #FFFFFF;
			width: 750rpx;
			padding: 40rpx;
			margin-bottom: 40rpx;

			.title_sub {
				display: flex;
				height: 66rpx;
				justify-content: space-between;
				align-items: center;

				.img_wrap {
					width: 66rpx;
					height: 66rpx;
					border-radius: 10rpx;
					overflow: hidden;
				}

				.img {
					width: 100%;
					height: 100%;
				}

				.title {
					flex: 1;
					padding-left: 20rpx;
					font-size: 32rpx;
					font-weight: bold;
					color: #333333;
				}

				.tips {
					border: 1rpx solid #585CF7;
					color: #585CF7;
					font-size: 22rpx;
					margin-left: 10rpx;
					padding: 0 8rpx;
				}

				.text {
					font-size: 24rpx;
					color: #999999;
				}
			}

			.brief {
				font-size: 28rpx;
				font-weight: 500;
				color: #333333;
				line-height: 36rpx;
				margin-top: 20rpx;
			}

			.con {
				background: #F8F8F8;
				border-radius: 8rpx;
				padding: 20rpx;
				margin: 20rpx 0;

				.yearRate {
					font-size: 28rpx;
					font-weight: bold;
					color: #333333;
					line-height: 34rpx;
					height: 34rpx;
				}

				.num {
					color: #FC4073;
					font-size: 34rpx;
				}

				.explain {
					font-size: 26rpx;
					font-weight: 500;
					color: #999999;
					line-height: 42rpx;
				}
			}

			.extract {
				font-size: 26rpx;
				font-weight: 500;
				color: #FC4073;
				line-height: 42rpx;
				margin: 30rpx 0 40rpx;
			}

			.btn_wrap {
				height: 80rpx;
				width: 100%;
				border-radius: 40rpx;
				overflow: hidden;
				display: flex;
				align-items: center;
				justify-content: space-between;
				border: 4rpx solid #585CF7;
				background: #585CF7;
				margin-top: 20rpx;

				.btn {
					flex: 1;
					background: #FFFFFF;
					font-size: 32rpx;
					height: 100%;
					color: #585CF7;
					line-height: 72rpx;
					border-radius: 0;
					outline: none;
				}

				.btn:after {
					border: unset;
					border-radius: unset;
				}

				.btn1 {
					color: #FFFFFF;
					background: #585CF7;
					border-radius: unset;
				}
			}
		}
	}
</style>
